package com.fin.quant.app.vo;

import cn.hutool.core.date.DateUtil;
import com.fin.quant.domain.entity.AssetEntity;
import com.fin.quant.instra.mysql.model.Asset;
import lombok.Data;

import java.util.List;

/**
 * 资产VO
 */
@Data
public class AssetVO {
    private Long id;
    private String assetCode;
    private String assetName;
    private String assetType; // 'stock' | 'fund' | 'crypto' | 'etf'
    private String market;
    private String currency;
    private String sector;
    private String country;
    //yyyy-MM-dd HH:mm:ss
    private String createdAt;
    //yyyy-MM-dd HH:mm:ss
    private String updatedAt;

    private double currentPrice;
    private double dividendYield;
    private double amountPerShare;

    private List<DividendHistoryVO> dividendHistoryList;

    private List<TagVO> tags;

    private List<MetricVO> metrics;

    public static AssetVO convertAssetToVO(AssetEntity asset) {
        AssetVO assetVO = new AssetVO();
        assetVO.setId(asset.getId());
        assetVO.setAssetCode(asset.getAssetCode());
        assetVO.setAssetName(asset.getAssetName());
        assetVO.setAssetType(asset.getAssetType());
        assetVO.setMarket(asset.getMarket());
        assetVO.setCurrency(asset.getCurrency());
        assetVO.setSector(asset.getSector());
        assetVO.setCountry(asset.getCountry());
        assetVO.setCreatedAt(DateUtil.format(asset.getCreatedAt(), "yyyy-MM-dd HH:mm:ss"));
        assetVO.setUpdatedAt(DateUtil.format(asset.getUpdatedAt(), "yyyy-MM-dd HH:mm:ss"));
        return assetVO;
    }

}
